package org.com.controller;

import javax.annotation.Resource;

import org.apache.log4j.Logger;
import org.com.service.ConnectionDataService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;

@Controller
@RequestMapping("/main")
public class MainControler {
	
	
	protected static Logger logger = Logger.getLogger("controller");
	
	
	
	public MainControler() {
		super();
	}

	@Resource(name="connectionDataService")
	private ConnectionDataService connectionDataService;
	
	   /**
     * Adds a new person by delegating the processing to PersonService.
     * Displays a confirmation JSP page
     * 
     * @return  the name of the JSP page
     */
    @RequestMapping(value = "/persons/add", method = RequestMethod.GET)
    public String add(
    		@RequestParam(value="browserName", required=true) String browserName)
    		 {
   
		logger.debug("Received request to add new data");
		
		// Call PersonService to do the actual adding
		connectionDataService.add(browserName);
		
		return "addedpage";
	}

}
